< previous page page_609 next page >

Page 609
z0629-01.gif
Figure 17.14
A point lies within a polygon if its projection lies
within the projection of the polygon.
The new PointInside routine shown in the following code first decides onto which plane it can project the polygon. It then calls function PointInsideXY, PointInsideYZ, or PointInsideXZ as necessary. The code that follows shows the PointInsideXY function. The other functions are very similar.
e10a6a0a59f035e870d90cca05b85fce.gif
' Return true if the point is in the polygon.
Private Function PointInside(ByVal X As Single, _
     ByVal Y As Single, ByVal Z As Single) As Boolean
Dim i As Integer
Dim xok As Boolean
Dim yok As Boolean
Dim zok As Boolean

    ' See in which coordinates the points differ.
    ' X coordinates.
    xok = False
    For i = 2 To NumPoints
        If Points(i - 1).Trans(1) <> Points(i).Trans(1) _
        Then
            xok = True
            Exit For
        End If
    Next i

    ' Y coordinates.
    yok = False
    For i = 2 To NumPoints
        If Points(i - 1).Trans(2) <> Points(i).Trans(2) _
        Then
            yok = True
            Exit For
        End If
    Next i

 
< previous page page_609 next page >